/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package persistence;

/**
 *
 * @author Clau
 */
import java.sql.Connection;
import java.sql.Date;
import model.Cliente;  
import java.sql.*;
import persistence.ConnectionFactory;
import java.sql.PreparedStatement;
  
public class ClienteDAO extends Dao {  
 private final Connection connection;
 private String nome;
 private String email;
 private String cpf;
 private Date dtnasc;
 private String sexo;
 private String endereco;
  
 public ClienteDAO() {
    this.connection = new ConnectionFactory().getConnection();
}

    @Override
    protected void open() throws Exception {
        super.open(); //To change body of generated methods, choose Tools | Templates.
    }
    
    public void adiciona(Cliente cliente) throws SQLException, Exception{  
        
     
        
      stmt = con.prepareStatement("INSERT INTO tb_cliente(nome, email, cpf, dtnasc, sexo, endereco ) VALUES(?,?,?,?,?,?)");  
       try{ 
      stmt.setString(1, cliente.getNome());  
      stmt.setString(2, cliente.getEmail());
      stmt.setString(3, cliente.getCpf());
      stmt.setDate(4, (Date) cliente.getDtNasc());
      stmt.setString(5, cliente.getSexo());
      stmt.setString(6, cliente.getEndereco());
      
        
        
      stmt.execute();        
       } catch (SQLException u){
           
           throw new RuntimeException(u);
       }
      
 close();
   }     
}  

